<template>
    <div>
        <h1>房号修改</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>房号</td>
                    <td>
                        <input type="text" v-model="data.Hnum" disabled>
                    </td>
                </tr>

                <tr>
                    <td>价格</td>
                    <td>
                        <input type="text" v-model="data.Price">
                    </td>
                </tr>

                <tr>
                    <td>状态</td>
                    <td>
                        <input type="radio" v-model="data.State" name="state" :value="true">开启
                        <input type="radio" v-model="data.State" name="state" :value="false">关闭
                    </td>
                </tr>

                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="修改" @click="Upts">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue';
import axios from 'axios';
import { useRoute } from 'vue-router';

const data=ref({
    "Id": 0,
  "Hnum": "",
  "Price": "",
  "State": true,
  "IsDel": true
})

//钩子
onMounted(() => {
    fts();
})

//修改
const Upts=()=>{
    debugger;
    axios.put("https://localhost:7133/api/House/Upthouse",data.value).then(res=>{
        if(res.data>0){
            alert("修改成功");
            location.href='/list';
        }else
        {
            alert("修改失败");
            return;
        }
    })
}

var touse=useRoute();
var ids=touse.query.id;
//反填
const fts=()=>{
    axios.get("https://localhost:7133/api/House/FTs",{params:{id:ids}}).then(res=>{
        data.value=res.data;
    })
}


</script>

<style scoped>

</style>